package com.fancon.rage.comic.entity;

import java.util.Date;

import javax.persistence.Id;

import com.googlecode.objectify.annotation.Indexed;
import com.googlecode.objectify.annotation.Unindexed;
/**
 * 
 * @author binhbt
 *
 */
public class Photo {

    @Id
    private Long id;
    private String title;
    private String caption;
    private String contentType;
    private byte[] thumbData;
    private byte[] photoData;
    private String thumbPath;
    private String photoPath;
    private String countryCode;
    private Date date = new Date();
    
    public Photo() {

    }

    public Photo(String title, String caption) {
        super();
        this.title = title;
        this.caption = caption;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getContentType() {
        return contentType;
    }

    public void setContentType(String contentType) {
        this.contentType = contentType;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getCaption() {
        return caption;
    }

    public void setCaption(String caption) {
        this.caption = caption;
    }

    public byte[] getPhotoData() {
        return photoData;
    }

    public void setPhotoData(byte[] photoData) {
        this.photoData = photoData;
    }

    public String getPhotoPath() {
        return photoPath;
    }

    public void setPhotoPath(String photoPath) {
        this.photoPath = photoPath;
    }

    public String getCountryCode() {
		return countryCode;
	}

	public void setCountryCode(String countryCode) {
		this.countryCode = countryCode;
	}


	public byte[] getThumbData() {
		return thumbData;
	}

	public void setThumbData(byte[] thumbData) {
		this.thumbData = thumbData;
	}

	public String getThumbPath() {
		return thumbPath;
	}

	public void setThumbPath(String thumbPath) {
		this.thumbPath = thumbPath;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	@Override
    public String toString() {
        return "Photo [id=" + id + ", title=" + title + ", caption=" + caption + ", contentType=" + contentType
                + ", photoPath=" + photoPath + "]";
    }
	public PhotoJson toJson(int mode){
		String thumbLink = (mode==0)?"/ragecomicvn?action=thumb&id="+id:"/ragecomicen?action=thumb&id="+id;
		String imageLink = (mode==0)?"/ragecomicvn?action=display&id="+id:"/ragecomicen?action=display&id="+id;
		PhotoJson json = new PhotoJson(id, title, thumbLink, imageLink,countryCode, date);
		return json;
	}
}
